package com.zyx.crawlerdemo.htmlxmlparse.jsoupxpath;

import java.util.List;
import org.seimicrawler.xpath.JXDocument;
import org.seimicrawler.xpath.JXNode;

/**
 * @author Yaxi.Zhang
 * @since 2021/8/12 09:55
 * desc: JsoupXpath案例
 */
public class JsoupXpathTest {
	public static void main(String[] args) {
		// 基于URL创建JXDocument
		JXDocument jxd = JXDocument.createByUrl("http://www.********.com.cn/b.asp");
		// Xpath语句
		String str = "//*[@id='course']/ul/li/a";  
		// 获取节点集合
		List<JXNode> list = jxd.selN(str);
		// 遍历节点
		for (JXNode node : list) {
			System.out.println("标题为:" + node.asElement().text() +
					"\tURL为:" + node.asElement().attr("href"));
		}
	}
}
